const Vue = require("../common/vue");
let order_service = require("../../service/order-service");
let _util = require('../../util/util');
require('../common/header/index')
require('../common/sidebar/index')

let order_all = new Vue({
    el: "#order-all",
    data() {
        return {
            orders: [],
        }
    },
    methods: {
        getOrders: function (_this) {
            let status = _util.getQueryVariable("status") || -1;
            if(status !== -1){
                $("#orderType").children().eq(status).addClass("active");
            } else{
                $("#orderType").children().eq(6).addClass("active");
            }
            order_service.getOrders(status, function (res) {
                _this.orders = res;
            }, function (err) {
                console.log(err);
            });
        },
        filter: function (status) {
            window.location.href = "/view/orders_all.html?status=" + status;
        },
        moveToDetail: function (orderID) {
            window.location.href = '/view/order_detail.html?orderID=' + orderID;
        }
    },
    created: function () {
        this.getOrders(this);
    }
});


